//
//  ZYTestView.m
//  ZYWebImage
//
//  Created by wangzhipan on 2025/5/9.
//

#import "ZYTestView.h"

@implementation ZYTestView

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
    if (self.userInteractionEnabled || self.hidden == YES) {
        return nil;
    }
    
    if ([self pointInside:point withEvent:event]) {
        for (UIView *subView in self.subviews.reverseObjectEnumerator) {
            CGPoint newPoint = [self convertPoint:point toView:subView];
            if ([subView pointInside:newPoint withEvent:event]) {
                UIView *hitView = [subView hitTest:newPoint withEvent:event];
                if (hitView) {
                    return hitView;
                }
            }
        }
        return self;
    }
    return nil;;
}

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
    if (point.x >= self.frame.origin.x && point.x <= self.frame.origin.x + self.frame.size.height / 2) {
        return YES;
    }
    return NO;
}

@end
